<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="js/jquery1.7.js"></script>
    <title>Document</title>
    <style>
    *{
        margin:0;
        padding:0;
    }
    ul{
        list-style: none;
    }
    .container ul li{
        width:100%;
        height:300px;
        line-height: 300px;
        text-align: center;

    }
    .scroll{
        display: none;
        position: fixed;
        right:50px;
        bottom:100px;
        width:100px;
        height: 500px;
        background: orange;
        text-align: center;
    }
    .scroll li{
        height: 100px;
        line-height: 100px;
    }
    </style>
</head>
<body>
    <div class="container">
        <ul>
            <li style="background-color: #0f0;">头部</li>
            <li style="background-color: #01A298;">banner图</li>
            <li style="background-color: #4AA667;">商品分类</li>
            <li style="background-color: #ff0000;">商品列表</li>
            <li style="background-color: #ff0;">热门商品</li>
            <li style="background-color: #EE441D;">底部</li>
        </ul>
    </div>
    <div class="scroll">
    <ul>
        <li>商品分类</li>
        <li>商品列表</li>
        <li>热门商品</li>
        <li>底部</li>
        <li>回到顶部</li>
    </ul>
    </div>
    <script>
      $(window).scroll(function(){
        //   //浏览器的高度
        //    console.log($(window).height());
        //    console.log($(window).scrollTop())
           var scroll=$(window).scrollTop();
           var height=$(window).height();
           if(scroll>height){
               $(".scroll").show();
           }
           else{
            $(".scroll").hide();
           }
      })
    //   点击固定电梯到对应哪个区域
       $(".scroll ul li").click(function(){
           var index=$(this).index();//每一个的索引
           if(index==4){
            $(document.body).animate({"scrollTop":0},1000);
            //谷歌
			$(document.documentElement).animate({"scrollTop":0},1000);
           }
           else if(index==0){
            $(document.body).animate({"scrollTop":600},1000);
            //谷歌
			$(document.documentElement).animate({"scrollTop":600},1000);
           }
           else if(index==1){
            $(document.body).animate({"scrollTop":900},1000);
            //谷歌
			$(document.documentElement).animate({"scrollTop":900},1000);
           }
           else if(index==2){
            $(document.body).animate({"scrollTop":1200},1000);
            //谷歌
			$(document.documentElement).animate({"scrollTop":1200},1000);
           }
           else{
            $(document.body).animate({"scrollTop":1500},1000);
            //谷歌
			$(document.documentElement).animate({"scrollTop":1500},1000);
           }
       })
    </script>
</body>
</html>